package com.lanmaoly.concurrent;

/**
 *
 */
public class Test1 {

    public static void main(String[] args) throws InterruptedException {
        // 线程1
        Thread threadOne = new Thread(() -> {
            for (; ; ) {

            }
        });
        final Thread mainThread = Thread.currentThread();
        // 线程2
        Thread threadTwo = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mainThread.interrupt();
        });

        threadOne.start();
        threadTwo.start();

        threadOne.join();
    }
}
